﻿using System.IO.Ports;
using TiaoTiaoCode.Common.Enums;

namespace TiaoTiaoCode.Modbuser.Interfaces
{

    /// <summary>
    /// ModbusRtu对象接口
    /// </summary>
    public interface IRtuModbuser : IModbuser
    {
        /// <summary>
        /// 串口名
        /// </summary>
        string PortName { get; }

        /// <summary>
        /// /波特率
        /// </summary>
        uint Baud { get; }

        /// <summary>
        /// 奇偶检验位
        /// </summary>
        Parity Parity { get; }

        /// <summary>
        /// 数据位
        /// </summary>
        ushort DataBit { get; }

        /// <summary>
        /// 停止位
        /// </summary>
        StopBits StopBit { get; }

        /// <summary>
        /// 设置
        /// </summary>
        /// <param name="portName">串口名</param>
        /// <param name="baud">波特率</param>
        /// <param name="parity">检验位</param>
        /// <param name="dataBit">数据位</param>
        /// <param name="stopBits">停止位</param>
        /// <returns></returns>
        IRtuModbuser SetConfig(string portName = "COM1", uint baud = 9600, Parity parity = Parity.None, ushort dataBit = 8, StopBits stopBits = StopBits.One);

        /// <summary>
        /// 设置站号
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        IRtuModbuser SetStation(byte station);

        /// <summary>
        /// 设置字节流顺序
        /// </summary>
        /// <param name="dataFormat"></param>
        /// <returns></returns>
        IRtuModbuser SetByteDataFormat(ByteDataFormatType dataFormat);

        /// <summary>
        /// 设置是否首地址为0
        /// </summary>
        /// <param name="addressStartWithZero"></param>
        /// <returns></returns>
        IRtuModbuser SetAddressStartWithZero(bool addressStartWithZero);

        /// <summary>
        /// 设置字符串是否反转
        /// </summary>
        /// <param name="isStringReverse"></param>
        /// <returns></returns>
        IRtuModbuser SetIsStringReverse(bool isStringReverse);

        /// <summary>
        /// 设置是否检查消息号一致
        /// </summary>
        /// <param name="checkMessageId"></param>
        /// <returns></returns>
        IRtuModbuser SetCheckMessageId(bool checkMessageId);
    }
}
